
package com.winning.sx.microframework.controller.sysmanage;

import com.fasterxml.jackson.databind.ObjectMapper;
import com.winning.dapi.data.entity.DataTable;
import com.winning.sx.microframework.model.message.AjaxTableResponseMessage;
import com.winning.sx.microframework.service.EasyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.Map;

@Controller
@RequestMapping(value = "/planLog")
public class PlanLogController {

    @Autowired
    private EasyService easyService;

    private ObjectMapper objectMapper = new ObjectMapper();
    //执行任务日志
    @RequestMapping(value = {"/",""})
    public ModelAndView planLog() {
        ModelAndView mv = new ModelAndView("/manage/planLog");
        return mv;
    }


    //执行任务日志-------查询功能
    @ResponseBody
    @RequestMapping(value = {"/queryList"})
    public AjaxTableResponseMessage queryMessageList(String datas) {
        AjaxTableResponseMessage ajaxTableResponseMessage = new AjaxTableResponseMessage();
        Map<String, String> param = null;
        ObjectMapper objectMapper = new ObjectMapper();
        try {
            if (datas != null)
                param = objectMapper.readValue(datas, Map.class);
            DataTable all = easyService.queryList("SYS_PlanLog",param);
            ajaxTableResponseMessage.setDatas(all.getDataRows());
            ajaxTableResponseMessage.setTotalSize((int) all.getTotalRowNum());
            ajaxTableResponseMessage.setSuccess(true);
        } catch (Exception e) {
            ajaxTableResponseMessage.setSuccess(false);
            ajaxTableResponseMessage.setErrorMsg("保存失败：" + e.getMessage());
        }
        return ajaxTableResponseMessage;
    }


}

